(function () { if (window.fakhamaGamesAdded) return; window.fakhamaGamesAdded = true; function addGames() { if (document.getElementById("fakhama-extra-games")) return; const items = [...document.querySelectorAll("button,a,div,span")] .filter(el => { const t = el.textContent.trim(); return t === "يوكام لودو" || t === "إكس أو"; }); if (!items.length) return; const target = items.sort( (a,b) => a.textContent.length - b.textContent.length )[0]; const menu = target.parentElement; if (!menu) return; const box = document.createElement("div"); box.id = "fakhama-extra-games"; const games = [ ["🧠 لعبة الذاكرة", "#9250a8", "memory"], ["🔢 تخمين الرقم", "#299e62", "guess"], ["✊ حجر وورقة ومقص", "#d05c50", "rps"], ["🎯 تحدي الذكاء", "#c49a36", "quiz"] ]; games.forEach(([name,color,type]) => { const btn = document.createElement("button"); btn.textContent = name; btn.style.cssText = "display:block;width:100%;padding:18px 8px;margin:5px 0;" + "border:1px solid #555;border-radius:6px;color:white;" + "font-size:20px;font-weight:bold;cursor:pointer;background:" + color; btn.onclick = () => openGame(type); box.appendChild(btn); }); menu.appendChild(box); } function openGame(type) { document.getElementById("fg-game-window")?.remove(); const win = document.createElement("div"); win.id = "fg-game-window"; win.dir = "rtl"; win.style.cssText = "position:fixed;inset:0;z-index:999999;background:#fff;" + "padding:20px;text-align:center;font-family:Arial;overflow:auto"; let html = ""; if (type === "guess") { html = `
خمن رقماً من 1 إلى 20
`; } if (type === "rps") { html = `اعثر على الصور المتشابهة
`; } if (type === "quiz") { html = `كم يساوي 7 × 8 ؟
`; } win.innerHTML = ` ${html} `; document.body.appendChild(win); win.querySelector("#fg-close").onclick = () => win.remove(); if (type === "guess") { let secret = Math.floor(Math.random()*20)+1; win.querySelector("#fg-check").onclick = () => { let n = Number(win.querySelector("#fg-input").value); let r = win.querySelector("#fg-result"); if (!Number.isInteger(n) || n<1 || n>20) { r.textContent = "اختر رقماً من 1 إلى 20"; } else if (n===secret) { r.textContent = "🏆 أحسنت! فزت"; secret = Math.floor(Math.random()*20)+1; } else { r.textContent = n